using System.Threading.Tasks;
using HengTong.ViewModel.SupplyChain.SysMaterialSkuVms;
using Microsoft.AspNetCore.Mvc;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;

namespace HengTong.Areas.SupplyChain.Controllers;

public partial class SysMaterialSkuController
{
    [AllRights]
    [ActionDescription("获取或创建SKU")]
    [HttpPost("GetOrCreate")]
    public async Task<IActionResult> GetOrCreate(GetOrCreateSkuRequest request)
    {
        var vm = Wtm.CreateVM<SysMaterialSkuVm>();
        await vm.GetOrCreateAsync(request);
        if (!ModelState.IsValid)
        {
            return BadRequest(ModelState.GetErrorJson());
        }
        else
        {
            return Ok(vm);
        }
    }
}